﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IPCPages
{
    public partial class FormConfirm : Form
    {
        private Image ShowImage = null;
        public FormConfirm(string photo)
        {
            ShowImage = Image.FromFile(photo);
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        public void OnCountdownCompleted(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void FormConfirm_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = ShowImage;
            countdownControl1.SetTextColor(Color.Yellow);
            countdownControl1.Start(OnCountdownCompleted);
        }

        private void FormConfirm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if(countdownControl1.IsRunning)
            {
                countdownControl1.Stop();
            }
        }
    }
}
